{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'\\n单独一个饼图\\n输入：指定时间段里的各项目以及各项目总分配工时\\n显示：指定时间端内的各项目分配工时占比\\n'"
      ]
     },
     "metadata": {},
     "execution_count": 1
    }
   ],
   "source": [
    "\"\"\"\n",
    "单独一个饼图\n",
    "输入：指定时间段里的各项目以及各项目总分配工时\n",
    "显示：指定时间端内的各项目分配工时占比\n",
    "\"\"\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import options as opts \n",
    "from pyecharts.charts import Pie "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset={'项目1':100,'项目2':50,'项目3':48,\"项目4\":88,\"项目5\":99,'项目6':31,'项目7':12,\"项目8\":22,\"项目9\":120}\n",
    "start_date='2020-09-01'\n",
    "end_date='2020-11-31'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": [
      "C:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\n"
     ]
    }
   ],
   "source": [
    "c=(Pie().\n",
    "    add('',\n",
    "        [ [k,v] for k,v in dataset.items()],\n",
    "        radius= 100,\n",
    "        \n",
    "    ).set_global_opts(title_opts=opts.TitleOpts(title='项目分配工时构成\\n\\n{}\\n-\\n{}'.format(start_date,end_date)),\n",
    "    legend_opts=opts.LegendOpts(pos_left=\"25%\"),)\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}/{c}\"))\n",
    "    .render('one_pie.html')\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}